local MainMenuFrame -- IMPORTANT!
 
function TeamDeathMatchMenu(ply)	-- This is obviously called when the command is run.
 
-- This checks to see if the menu is already open
if MainMenuFrame then
MainMenuFrame:Remove()	-- Remove the menu and set the value to nil
MainMenuFrame = nil
return	-- Exit the function to prevent the menu from geting created again.
end
 
-- Create the frame, since it doesn't exist
MainMenuFrame = vgui.Create( "DFrame" )
MainMenuFrame:SetSize( 600, 250 )
MainMenuFrame:SetTitle("Team Deathmatch Menu: Version" )
MainMenuFrame:Center()
MainMenuFrame:ShowCloseButton( true )
MainMenuFrame:SetDraggable( false )
 
 
function MainMenuFrame:Paint( w, h )
draw.RoundedBox( 0, 0, 0, w, h, Color(team.GetColor(LocalPlayer():Team()).r,team.GetColor(LocalPlayer():Team()).g,team.GetColor(LocalPlayer():Team()).b,50))
surface.SetDrawColor(0,0,0)
surface.DrawOutlinedRect(1,1,w-1,h-1)
end
 
MainMenuFrame:SetVisible( true )	-- You forgot to add these two lines in your second example, which is probably why nothing happened.
MainMenuFrame:MakePopup( true )
 
end
 
concommand.Add( "TeamDeathMatchMenu", TeamDeathMatchMenu )